package jdbc.demo.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 描述:
 *
 * @author Zhanggq
 * @date 2019/9/17 10:12
 */
public class JdbcTool {
    public static final String driverClassName = "com.mysql.jdbc.Driver";
    public static final String url = "数据库url";
    public static final String username = "用户名";
    public static final String password = "用户密码";

    static {
        try {
            Class.forName(driverClassName);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection(url, username, password);
            return connection;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
